# -*- coding: utf-8 -*-
# !/usr/bin/env python

import multiprocessing
import time


def func(interval):
    time.sleep(interval)
    return interval*interval


if __name__ == "__main__":
    result = []
    start = time.time()
    pool = multiprocessing.Pool(processes=8)
    for i in range(1, 5):
        result.append(pool.apply_async(func, (i,)))
    pool.close()
    pool.join()
    end = time.time()
    print(end - start)
    print("任务结束!!!")
    
    # 查看结果
    for res in result:
        print(res.get())